package us.nchu.tomtiger.service;

import org.springframework.stereotype.Service;
import us.nchu.tomtiger.dao.UserShowDao;
import us.nchu.tomtiger.model.User;
import us.nchu.tomtiger.model.UserShow;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by XiongXuan on 2018/1/8.
 */
@Service
public class UserShowService {
    @Resource
    private UserShowDao userShowDao;

    public void createShow(UserShow userShow) {
        userShowDao.insert(userShow);
    }

    public UserShow getUserShowByShowId(String id) {
        return userShowDao.queryByShowId(id);
    }

    public UserShow getUserShowByUserId(String id) {
        return userShowDao.queryByUserId(id);
    }

    public List<UserShow> queryForUserShowListByUserList(List<User> users) {
        List<UserShow> userShows = new ArrayList<>();

        for (User user : users) {
            userShows.add(userShowDao.queryByUserId(user.getPhoneNumber()));
        }
        return userShows;
    }
}
